home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / SC #49.sit / THINK C Tutor Folder / MacTutor.c next >
C/C++ Source or Header  |  1989-08-12  |  1KB  |  103 lines

  1. /* MacTutor.c */
  2.  
  3. #include <CApplication.h>
  4. #include <CDesktop.h>
  5. #include <CDirector.h>
  6. #include <commands.h>
  7.  
  8. struct CTutorApp : CApplication
  9.     {
  10.     /* no instance variables */
  11.     
  12.     /* instance methods */
  13.     void ITutorApp(void);
  14.     void DoCommand(long theCommand);
  15.     };
  16.     
  17. struct CTutorDir : CDirector
  18.     {
  19.     /* CDirector is an abstract class, so we must override it */
  20.     void ITutorDir(void);
  21.     };
  22.  
  23. struct CTutorWindow : CWindow
  24.     {
  25.     /* want to override close for our own nefarious purposes */
  26.     void Close();
  27.     };
  28.  
  29. extern CApplication *gApplication;
  30. extern CDesktop *gDesktop;
  31.  
  32. void main(void)
  33. {
  34.  
  35.     gApplication = new(CTutorApp);
  36.     ((CTutorApp*)gApplication)->ITutorApp();
  37.  
  38.     gApplication->Run();
  39.     
  40.     gApplication->Exit();
  41.     
  42. }    /* main */
  43.  
  44.  
  45. void CTutorApp::DoCommand(long theCommand)
  46. {
  47.  
  48.     switch (theCommand)
  49.         {
  50.         
  51.         default:
  52.             inherited::DoCommand(theCommand);
  53.             break;
  54.             
  55.         }    /* switch */
  56.         
  57.     return;
  58.     
  59. }    /* CTutorApp::DoCommand */
  60.  
  61.  
  62. void CTutorApp::ITutorApp()
  63. {
  64.  
  65.     CTutorDir *ourDirector;
  66.  
  67.     CApplication::IApplication(4, 20000L, 2000L);
  68.     
  69.     ourDirector = new(CTutorDir);
  70.     ourDirector->ITutorDir();
  71.     
  72.     return;
  73.     
  74. }    /* CTutorApp::ITutorApp */
  75.  
  76.  
  77. void CTutorDir::ITutorDir()
  78. {
  79.  
  80.     CDirector::IDirector(gApplication);
  81.     
  82.     itsWindow = (CWindow *) new(CTutorWindow);
  83.     itsWindow->IWindow(2000, FALSE, gDesktop, this);
  84.     
  85.     return;
  86.     
  87. }    /* CTutorDir::ITutorDir */
  88.  
  89.  
  90. void CTutorWindow::Close(void)
  91. {
  92.  
  93.     inherited::Close();
  94.     gApplication->Quit();
  95.     
  96.     return;
  97.     
  98. }    /* CTutorWindow::Close */
  99.  
  100.  
  101. /* EOF: MacTutor.c */
  102.  
  103.